import { store } from "quasar/wrappers";
import { createStore } from "vuex";
import persistedstate from "vuex-persistedstate";
import persisted from "./persisted";
import common from "./common";

/*
 * If not building with SSR mode, you can
 * directly export the Store instantiation;
 *
 * The function below can be async too; either use
 * async/await or return a Promise which resolves
 * with the Store instance.
 */

export default store(function (/* { ssrContext } */) {
  const Store = createStore({
    modules: {
      persisted,
      common,
    },

    // enable strict mode (adds overhead!)
    // for dev mode and --debug builds only
    strict: process.env.DEBUGGING,
    plugins: [
      persistedstate({
        key: "persistedstate-dingpa",
        paths: ["persisted"],
      }),
    ],
  });

  return Store;
});
